﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using makitRS.Core.Models.Reports;
using makitRS.Core.Reports;

namespace makitRS.WebUI.Controllers
{
    public class ReportController : Controller
    {
        //
        // GET: /Reports/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Display(int id)
        {
            return View();
        }

        public ActionResult Download(int id)
        {
            Report rep = ReportManager.getReport(id);

            if (rep == null)
            {
                return Content("Not Found");
            }
            else
            {
                DownloadableReport castRep = (DownloadableReport)rep;

                return File("~/App_Data/Reports/" + castRep.FileName, castRep.ContentType, castRep.FileName);
            }
        }
    }
}
